<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <textarea id="txt"> </textarea>
  <button id="btn">点击事件</button>
  <div id="show"></div>
  <!-- 6.判断任意一个字符串大写字母 小写字母  数字  和 其他字符的个数    例：  "str>=a"&&str<="z" 为小写字母 -->
  <script>
    var txt = document.getElementById("txt"); //输入框
    var btn = document.getElementById("btn");//点击事件
    var show = document.getElementById("show")
    btn.onclick = function () {
      var txtVal = txt.value; //输入框值 asdfh23434&*AFA
      var big = 0;//大写字母
      var small = 0;//小写字母
      var num = 0;//数字
      var other = 0;//其他字符
      for (var i = 0; i < txtVal.length; i++) {

        if (txtVal[i] >= "a" && txtVal[i] <= "z") {
          small++
        } else if (txtVal[i] >= "A" && txtVal[i] <= "Z") {
          big++
        } else if (txtVal[i] >= 0 && txtVal[i] <= 9 && txtVal[i] != " ") {
          num++
        } else {
          other++
        }
      }
      show.innerHTML = `大写字母${big}个,小写字母${small}个,数字有${num}个,其他字符${other}个`
    }
  </script>
</body>

</html>